package org.example.product.controller;

import org.example.core.utils.R;
import org.example.product.service.ProductService;
import org.example.product.vo.SpuRestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 小杰_cc
 * @version 1.0
 */
@RestController
@RequestMapping("/pms/backend/over")
public class ProductBackendController {

    @Autowired
    private ProductService productService;

    /**
     * 创建商品
     */
    @PostMapping("/save")
    public R<?> save(@RequestBody SpuRestVo spuRestVo) {
        productService.saveProduct(spuRestVo);
        return R.ok();
    }

    /**
     * 上架
     */
    @PostMapping("/up/{spuId}")
    public R<?> up(@PathVariable("spuId") Long spuId){
        productService.productUp(spuId);
        return R.ok();
    }

    /**
     * 下架
     */
    @PostMapping("/down")
    public R<?> down(@RequestBody List<Long> spuIds){
        return productService.productDown(spuIds);
    }
}
